<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0,minimum-scale=1,maximum-scale=1,user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <!--     <link rel="stylesheet" type="text/css" href="css/index.css"> -->
    <script type="text/javascript" src="js/tools.js"></script>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }

        ul,
        li {
            list-style: none;
        }
    </style>
    <title>Document</title>
</head>

<body>
    <div class="search">
        <button class='search-btn'>查询</button>
    </div>
    <ul class="img-box">
    </ul>
    <script>
        $('.search-btn').addEventListener('click', () => {
            const xhr = new XMLHttpRequest()
            const url =
                'http://route.showapi.com/1287-1?showapi_appid=754868&showapi_sign=fe4fb8b97bc0472cbc4abff2a6aaeaab'
            xhr.open('GET', url, true)
            xhr.send()
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4 && xhr.status === 200) {
                    let data = xhr.responseText
                    data = JSON.parse(data)
                    const {
                        img_1920
                    } = data.showapi_res_body.data
                    const res = `<li><img src="${img_1920}" alt=""></li>`
                    $('.img-box').innerHTML = res
                    let cw = document.documentElement.clientWidth
                    let ch = document.documentElement.clientHeight
                    $('.img-box li img').style.width = cw + 'px'
                    $('.img-box li img').style.height = ch + 'px'
                }
            }

        })
    </script>
</body>

</html>